package com.platform.modules.report.service;

import com.platform.common.utils.MapUtil;
import com.platform.modules.report.dao.PrjReportDao;
import com.platform.modules.report.dto.BaseQueryDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class PrjReportService {

    @Autowired
    PrjReportDao prjReportDao;


    public Integer memberNumber(BaseQueryDTO baseQueryDTO){
        return prjReportDao.memberNumber(baseQueryDTO);
    }

    public Integer prjCount(BaseQueryDTO baseQueryDTO) {
        return prjReportDao.prjCount(baseQueryDTO, null);
    }

    public Integer prjCount(BaseQueryDTO baseQueryDTO, Map<Object,Object> extra) {
        return prjReportDao.prjCount(baseQueryDTO, extra);
    }

    public Map<String, Object> prjCountGroupByScale(BaseQueryDTO baseQueryDTO) {
        List<Map<String,Object>> list =  prjReportDao.prjCountGroupByScale(baseQueryDTO);
        return MapUtil.flat(list,"TYPE","VALUE");
    }

    public Map<String, Object> prjCountGroupByPurpose(BaseQueryDTO baseQueryDTO) {
        List<Map<String,Object>> list =  prjReportDao.prjCountGroupByPurpose(baseQueryDTO);
        return MapUtil.flat(list,"TYPE","VALUE");
    }

    public Map<String, Object> prjCountGroupByCity(BaseQueryDTO baseQueryDTO) {
        List<Map<String,Object>> prjCountList = prjReportDao.prjCountGroupByCity(baseQueryDTO);
        return MapUtil.flat(prjCountList,"CITY_NUM","COUNT");
    }

    public Map<String, Object> prjTotalAreaGroupByCity(BaseQueryDTO baseQueryDTO) {
        List<Map<String,Object>> prjCountList = prjReportDao.prjTotalAreaGroupByCity(baseQueryDTO);
        return MapUtil.flat(prjCountList,"CITY_NUM","SUM");
    }

    public Map<String, Object> prjTotalInvestmentGroupByCity(BaseQueryDTO baseQueryDTO) {
        List<Map<String,Object>> prjCountList = prjReportDao.prjTotalInvestmentGroupByCity(baseQueryDTO);
        return MapUtil.flat(prjCountList,"CITY_NUM","SUM");
    }

    public Map<String, Object> importantPrjCountGroupByCity(BaseQueryDTO baseQueryDTO) {
        List<Map<String,Object>> prjCountList = prjReportDao.importantPrjCountGroupByCity(baseQueryDTO);
        return MapUtil.flat(prjCountList,"CITY_NUM","COUNT");
    }

    public Map<String, Object> zpsCountGroupByCity(BaseQueryDTO baseQueryDTO) {
        List<Map<String,Object>> prjCountList = prjReportDao.zpsCountGroupByCity(baseQueryDTO);
        return MapUtil.flat(prjCountList,"CITY_NUM","COUNT");
    }

    public Map<String, Object> bdfCountGroupByCity(BaseQueryDTO baseQueryDTO) {
        List<Map<String,Object>> prjCountList = prjReportDao.bdfCountGroupByCity(baseQueryDTO);
        return MapUtil.flat(prjCountList,"CITY_NUM","COUNT");
    }

    public Map<String, Object> prjCountGroupByYear(BaseQueryDTO baseQueryDTO) {
        List<Map<String,Object>> prjCountList = prjReportDao.prjCountGroupByYear(baseQueryDTO);
        return MapUtil.flat(prjCountList,"YEAR","COUNT");
    }

    public Map<String, Object> prjTotalAreaGroupByYear(BaseQueryDTO baseQueryDTO) {
        List<Map<String,Object>> prjCountList = prjReportDao.prjTotalAreaGroupByYear(baseQueryDTO);
        return MapUtil.flat(prjCountList,"YEAR","SUM");
    }

    public Map<String, Object> prjTotalInvestmentGroupByYear(BaseQueryDTO baseQueryDTO) {
        List<Map<String,Object>> prjCountList = prjReportDao.prjTotalInvestmentGroupByYear(baseQueryDTO);
        return MapUtil.flat(prjCountList,"YEAR","SUM");
    }

    public Map<String, Object> zpsCountGroupByYear(BaseQueryDTO baseQueryDTO) {
        List<Map<String,Object>> prjCountList = prjReportDao.zpsCountGroupByYear(baseQueryDTO);
        return MapUtil.flat(prjCountList,"YEAR","COUNT");
    }

    public Map<String, Object> bdfCountGroupByYear(BaseQueryDTO baseQueryDTO) {
        List<Map<String,Object>> prjCountList = prjReportDao.bdfCountGroupByYear(baseQueryDTO);
        return MapUtil.flat(prjCountList,"YEAR","COUNT");
    }

    public Integer pauseCount(BaseQueryDTO baseQueryDTO) {
        return prjReportDao.pauseCount(baseQueryDTO);
    }

}
